﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.Xml.Serialization;
using System.Diagnostics;

namespace Sinacor.Infra.Tools.ErrorLogCollector
{
    [Serializable]
    public enum LogSource
    {
        UserInterface,
        ProcessManager,
        Hoster,
        Logging,
        SecurityTokenService,
        WcfServices
    }

    [Serializable]
    public abstract class LogData
    {
        [XmlAttribute]
        public LogSource LogSource { get; set; }
        [XmlAttribute]
        public DateTime Date { get; set; }
    }

    [Serializable]
    public abstract class LogData<TContent> : LogData
    {
        [XmlElement]
        public TContent Content { get; set; }
    }

    [Serializable]
    public class EventLogData : LogData<string>
    {
        [XmlAttribute]
        public string EventLogSource { get; set; }
        [XmlAttribute]
        public string EventLogCategory { get; set; }
        [XmlAttribute]
        public EventLogEntryType EventLogType { get; set; }
        [XmlAttribute]
        public long EventLogId { get; set; }
        [XmlAttribute]
        public string EventLogUserName { get; set; }
        [XmlAttribute]
        public string EventLogMachineName { get; set; }
    }

    [Serializable]
    public class FileLogData : LogData<System.Xml.Linq.XElement>
    {
        [XmlAttribute]
        public string FileLogName { get; set; }
        [XmlAttribute]
        public string FileLogPath { get; set; }
    }

    [Serializable]
    public class DbLogData : LogData<string>
    {
        public DbLogData()
        {
            this.Detalhes = new List<DbLogDataDetail>();
        }

        [XmlAttribute]
        public int DbLogCodigo { get; set; }
        [XmlAttribute]
        public int DbLogCodigoTipo { get; set; }

        [XmlAttribute]
        public string DbLogNomeClasse { get; set; }
        [XmlAttribute]
        public string DbLogNumeroIp { get; set; }
        [XmlAttribute]
        public string DbLogCodigoIdtSessaoUsuario { get; set; }

        [XmlArray]
        public List<DbLogDataDetail> Detalhes { get; set; }
    }

    [Serializable]
    public class DbLogDataDetail
    {
        [XmlAttribute]
        public int DbLogCodigo { get; set; }
        [XmlAttribute]
        public int DbLogCodigoDetalhe { get; set; }
        [XmlAttribute]
        public string DbLogNomeDetalhe { get; set; }

        [XmlElement]
        public string DbLogConteudo { get; set; }
    }

}
